package org.jash.sportnews2109.vm

import androidx.lifecycle.MutableLiveData
import dagger.hilt.android.lifecycle.HiltViewModel
import org.jash.common.mvvm.BaseViewModel
import org.jash.sportnews2109.dao.NewsDao
import org.jash.sportnews2109.entity.News
import javax.inject.Inject

@HiltViewModel
class SearchViewModel @Inject constructor(val newsDao: NewsDao):BaseViewModel() {
    val newsLiveData by lazy { MutableLiveData<List<News>>() }
    fun search(key:String) {
        progress(newsDao.searchByKeyword("%$key%"), newsLiveData::postValue)
    }
}